<template>
  <div>
    <FilterTable
      ref="table"
      :columns="columns"
      columnsRef="partPartPurchasePurchaseOrderCreateSetMealSelect"
      :fetchapi="fetchapi"
      :params="fetchParams"
      :datakey="'rows'"
      selectionType="single"
      :onRowSelectChange="handleTableRowSelect"
      :onColumnsChange="columns => (this.columns = columns)"
    ></FilterTable>
    <div class="btnWrap">
      <el-button @click="handleCancle">取消</el-button>
      <el-button type="primary" @click="handleConfirm">确定</el-button>
    </div>
  </div>
</template>

<script>
import { querySetMealList } from '@/api/part/partPurchase/purchaseOrder';

export default {
  data() {
    return {
      columns: this.createTableColumn(),
      fetchapi: querySetMealList,
      fetchParams: {},
      setlectedTableRowData: [] // 选中的table数据
    };
  },
  methods: {
    createTableColumn() {
      return [
        {
          title: '套餐代码',
          dataIndex: 'tcCode',
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // table数据选择
    handleTableRowSelect(e) {
      this.setlectedTableRowData = e;
    },
    // 点击确定
    handleConfirm() {
      this.$emit('onConfirm', this.setlectedTableRowData);
      this.handleCancle();
    },
    // 关闭
    handleCancle() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.btnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
